<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateDelayOrderTable extends AbstractMigration
{
    public function up()
    {
        $table = $this->table('delay_order', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '延期单']);
        $table->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '主键ID'])
            ->addColumn('number', 'string', ['default' => '', 'limit' => 15, 'comment' => '工单号'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 128, 'comment' => '延期单名'])
            ->addColumn('project_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'default' => 0, 'comment' => '项目id'])
            ->addColumn('episode_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'default' => 0, 'comment' => '集id'])
            ->addColumn('is_reviewed', 'enum', ['values' => 'yes,no', 'default' => 'no', 'comment' => '是否审核'])
            ->addColumn('step_category_id', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'default' => 0, 'comment' => '工序环节id'])
            ->addColumn('plan_delivery_time', 'integer', ['limit' => 11, 'null' => false, 'signed' => false, 'default' => 0, 'comment' => '创建时的计划交付时间'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建人'])
            ->addColumn('created', 'integer', ['signed' => false, 'null' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间']);
        // 创建表
        $table->create();
    }

    public function down()
    {
        $this->table('delay_order')->drop()->save();
    }
}
